<template>
  <div class="businessManagement">
    <el-form label-width="120px">
      <el-form-item label="城市">
        <el-cascader
          style="width: 100%"
          size="large"
          :props="{ multiple: true }"
          :options="options"
          v-model="searchParams.marketList"
          @change="handleChange">
        </el-cascader>
      </el-form-item>
      <el-form-item label="公司名称/税号">
        <el-input
          style="width: 30%"
          v-model="searchParams.code"
          placeholder="请输入公司名称/税号"
          clearable>
        </el-input>
      </el-form-item>
      <el-form-item label="评估年度">
        <el-date-picker
          style="width: 30%"
          v-model="searchParams.year"
          type="year"
          value-format="yyyy"
          format="yyyy"
          placeholder="评估年度">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="效益评估">
        <el-select
          style="width: 100%"
          multiple
          v-model="searchParams.payTaxesList"
          placeholder="请选择">
          <el-option label="0" value="0,0"></el-option>
          <el-option label="0-2万" value="0,2"></el-option>
          <el-option label="2-5万" value="2,5"></el-option>
          <el-option label="5-10万" value="5,10"></el-option>
          <el-option label="10-16万" value="10,16"></el-option>
          <el-option label="16-20万" value="16,20"></el-option>
          <el-option label="20-30万" value="20,30"></el-option>
          <el-option label="30-40万" value="30,40"></el-option>
          <el-option label="40-50万" value="40,50"></el-option>
          <el-option label="50-60万" value="50,60"></el-option>
          <el-option label="60-80万" value="60,80"></el-option>
          <el-option label="80-100万" value="80,100"></el-option>
          <el-option label="100万以上" value="100,undefined"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="规模评估">
        <el-select
          style="width: 100%"
          multiple
          v-model="searchParams.businessList"
          placeholder="请选择">
          <el-option label="0" value="0,0"></el-option>
          <el-option label="0-50万" value="0,50"></el-option>
          <el-option label="50-100万" value="50,100"></el-option>
          <el-option label="100-200万" value="100,200"></el-option>
          <el-option label="200-500万" value="200,500"></el-option>
          <el-option label="500-800万" value="500,800"></el-option>
          <el-option label="800-1000万" value="800,1000"></el-option>
          <el-option label="1000-1500万" value="1000,1500"></el-option>
          <el-option label="1500-2000万" value="1500,2000"></el-option>
          <el-option label="2000-3000万" value="2000,3000"></el-option>
          <el-option label="3000-4000万" value="3000,4000"></el-option>
          <el-option label="4000-5000万" value="4000,5000"></el-option>
          <el-option label="5000-6000万" value="5000,6000"></el-option>
          <el-option label="6000-8000万" value="6000,8000"></el-option>
          <el-option label="8000万-1亿" value="8000,10000"></el-option>
          <el-option label="1亿以上" value="10000,undefined"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="资产评估">
        <el-select
          style="width: 100%"
          multiple
          v-model="searchParams.propertyList"
          placeholder="请选择">
          <el-option label="0" value="0,0"></el-option>
          <el-option label="0-50万" value="0,50"></el-option>
          <el-option label="50-100万" value="50,100"></el-option>
          <el-option label="100-200万" value="100,200"></el-option>
          <el-option label="200-500万" value="200,500"></el-option>
          <el-option label="500-800万" value="500,800"></el-option>
          <el-option label="800-1000万" value="800,1000"></el-option>
          <el-option label="1000-2000万" value="1000,2000"></el-option>
          <el-option label="2000-3000万" value="2000,3000"></el-option>
          <el-option label="3000-5000万" value="3000,5000"></el-option>
          <el-option label="5000-8000万" value="5000,8000"></el-option>
          <el-option label="8000万-1亿" value="8000,10000"></el-option>
          <el-option label="1亿以上" value="10000,undefined"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="负债评估">
        <el-select
          style="width: 100%"
          multiple
          v-model="searchParams.liabilitiesList"
          placeholder="请选择">
          <el-option label="0" value="0,0"></el-option>
          <el-option label="0-50万" value="0,50"></el-option>
          <el-option label="50-100万" value="50,100"></el-option>
          <el-option label="100-200万" value="100,200"></el-option>
          <el-option label="200-500万" value="200,500"></el-option>
          <el-option label="500-800万" value="500,800"></el-option>
          <el-option label="800-1000万" value="800,1000"></el-option>
          <el-option label="1000-2000万" value="1000,2000"></el-option>
          <el-option label="2000-3000万" value="2000,3000"></el-option>
          <el-option label="3000-5000万" value="3000,5000"></el-option>
          <el-option label="5000-8000万" value="5000,8000"></el-option>
          <el-option label="8000万-1亿" value="8000,10000"></el-option>
          <el-option label="1亿以上" value="10000,undefined"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          @click="initTable">
          查一下
        </el-button>
      </el-form-item>
    </el-form>
    <el-alert
      v-if="resultParams.id"
      show-icon
      :closable="false"
      type="success">
      <template #title>
        <span>本次查询结果{{resultParams.sum}}条，点击查看</span>
        <el-button
          @click="handleCheckDetail"
          type="text">
          点击查看
        </el-button>
      </template>
    </el-alert>
  </div>
</template>
<script>
import { provinceAndCityData, CodeToText, pcTextArr } from 'element-china-area-data'
import { getEnterpriseManagement } from "@/api/businessManagement";
import {getToken} from "@/utils/auth";
import router from '@/router';
export default {
  data() {
    return {
      options: pcTextArr,

      searchParams: {
        marketList: "",
        code: "",
        year: "",
        payTaxesList: [],     //效益评估
        businessList: [],     //规模评估
        propertyList: [],     //资产评估
        liabilitiesList: [],  //负债评估
        type: '2'
      },
      resultParams: {
        sum: 0,
        id: undefined
      },
    }
  },
  methods: {
    handleChange (value) {
      console.log(value)
    },
    formatParams(list) {
      return list.map(item => {
        const a = item.split(',');
        return {
          fromData: Number(a[0]),
          toData: a[1] === 'undefined' ? '' : Number(a[1]),
        }
      })
    },
    initTable() {
      let {payTaxesList, businessList, propertyList, liabilitiesList, marketList} = this.searchParams;
      const params = {
        ...this.searchParams,
        payTaxesList: this.formatParams(payTaxesList),
        businessList: this.formatParams(businessList),
        propertyList: this.formatParams(propertyList),
        liabilitiesList: this.formatParams(liabilitiesList),
        marketList: !!marketList.length ? marketList.map(item => item[1]) : [],
      }
      getEnterpriseManagement(params).then(res => {
        const { code, data } = res;
        const { sum, id } = res.data;
        this.resultParams = { sum, id }
      })
    },
    handleCheckDetail() {
      const id = this.resultParams.id;
      router.push({ path: '/resultSearch', query: { id } });
    }
  }
}
</script>
<style lang="scss" scoped>
div.businessManagement {

}
</style>

